<template>
    <div class="box">
        <header class="header">我的</header>
        <div class="content">
            用户名：{{ username }}
            <van-button type="default" @click="loginout">退出登录</van-button>
            <div>
                <van-button type="warning" @click="$router.push('/user/myorder')">查看我的订单</van-button>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            username: localStorage.getItem('username')
        }
    },
    methods: {
        loginout() {
            // 清除token
            localStorage.removeItem('token')
            // 清除用户名
            localStorage.removeItem('username')
            // 跳转到登录页
            this.$router.push('/login')
        }
    }
}
</script>